package com.wnxy.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wnxy.dto.RolePathDto;
import com.wnxy.dto.StatusCode;
import com.wnxy.exception.UpdateException;
import com.wnxy.mapper.ManagerMapper;
import com.wnxy.model.Manager;
import com.wnxy.model.Role;
import com.wnxy.mapper.RoleMapper;
import com.wnxy.service.ManagerService;
import com.wnxy.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author alice
 * @since 2021-11-12
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Autowired
private ManagerService managerService;
    @Autowired
    private RedisTemplate<String,Object> rt;
    @Override
    public void addRole(String roleName) {
        if(roleName==null||"".equals(roleName)) throw new UpdateException(StatusCode.UPERROR.getCode(), "请输入角色名");
        Role role = new Role();
        role.setRoleName(roleName);
        role.setRoleStatus(0);
        boolean save = save(role);
        if(!save) throw new UpdateException(StatusCode.UPERROR.getCode(), "保存角色失败");
    }

    @Override
    public Map<Integer, List<RolePathDto>> loadRolePath() {
        return null;
    }

}
